package cn.qihua.action;

import cn.qihua.model.SysUser;
import cn.qihua.service.IUserService;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author 米修
 * 
 */

public class RegisterAction extends ActionSupport {
	private static final long serialVersionUID = -3676368444792994304L;
	public String message;
	private boolean success = false;
	private IUserService sysUserService;
	public SysUser user = new SysUser();
	public String password;

	@Override
	public String execute() {
		if (user != null && !user.getUsername().equals("")) {
			if (sysUserService.register(user)) {
				this.setSuccess(true);
				this.setMessage("恭喜，注册成功！请等待管理员审核。");
				return SUCCESS;
			}
		}
		this.setSuccess(false);
		this.setMessage("用户名或已存在，请重试！");
		return ERROR;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public SysUser getUser() {
		return user;
	}

	public void setUser(SysUser user) {
		this.user = user;
	}

	public void setSysUserService(IUserService sysUserService) {
		this.sysUserService = sysUserService;
	}
}
